# 1.配置实验环境
import matplotlib.pyplot as plt # 导入pyplot模块
plt.rcParams['font.sans-serif'] = ['SimHei'] # 解决中文乱码问题
plt.rcParams['axes.unicode_minus'] = False # 解决正负号乱码问题
# 2.准备实验数据，x对应房屋面积，y对应房屋价格
x = [52.71, 60.77, 83.35, 77.49, 32.9, 76.18, 63.48, 77.41, 86.75, 80.69,91.23, 81.16, 85.13,
     65.85, 37.11, 77.83, 62.12,41.28, 66.9, 86.95,75.1, 43.08, 59.1, 97.66, 50.06, 107.09,
     65.49, 98.2, 88.97, 111.42,86.95, 73, 108.51, 28.79, 53.79,89.64, 107.6, 75.66, 97.03, 90.91, 84.65,
     32.06, 35.56, 89.19, 23.06, 50, 39.5, 50.96, 44.81, 76.9]
y = [358, 420, 588, 588, 295, 499, 815, 535, 698, 660, 595, 530, 605, 465, 285, 575, 480, 276, 451, 585, 661,
     250, 405,575, 700, 758, 470, 618, 830, 850, 575,478, 830, 290, 660, 670, 880, 620, 735, 630, 618, 375,
     240, 660, 160, 350, 368,350, 380, 490]
# 3.创建画布
plt.figure(figsize=(12, 6), dpi=150)
# 4.绘制图像
plt.scatter(x, y)
# 5.修饰图像
plt.title("深圳市福田区二手房面积与售价关系图", fontsize=16) # 添加标题
plt.xlabel("房屋面积（单位：平方米）") # 添加x轴标签
plt.ylabel("房屋售价（单位：万）") # 添加y轴标签
plt.grid(linestyle="--", alpha=0.2) # 添加网格
plt.xticks(range(20, 120, 5)) # 重设x轴刻度
plt.show()